package domain

import "time"

type Article struct {
	Id      int64
	Title   string
	Content string
	Author  Author
	Status  ArticleStatus

	Ctime time.Time
	Utime time.Time
}

func (a Article) AbStract() string {
	cont := []rune(a.Content)
	if len(cont) <= 100 {
		return a.Content
	}

	return string(cont[:100])
}

// 帖子领域中没有用户的概念，只有作者和读者
type Author struct {
	Id       int64
	Nickname string
}

type ArticleStatus uint8

const (
	ArticleStatusUnKnow ArticleStatus = iota
	ArticleStatusUnPublished
	ArticleStatusPublished
	ArticleStatusPrivate
)

func (s ArticleStatus) Uint8() uint8 {
	return uint8(s)
}
